package com.tony.model;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class DeviceInfo {


    public long id;
    public String androidId;			//安卓id
    public long allMemory;				//总机身内存       128G，存全部数字
    public long allRomMemory;			//总rom内存     6G	手机运行内存
    public long availSpaceOfData;		//总sd卡内存	32G sd卡内存
    public String appVersion;			//获取数据的应用的版本名
    public int appVersionCode;			//获取数据的应用的版本号
    public String accountCenterVersion;	//设备带有的会员中心的版本名
    public int accountCenterVersionCode;//设备带有的会员中心的版本号


    public String brand;
    public String board;
    public String baseOS;
    public String bootloader;
    public String buildId;			//fingerprint信息的第四位：OPPO/A59m/A59:5.1/LMY47I/1449641681:user/release-keys  LMY47I
    public String basebandVersion;	//设备基带版本 gsm.version.baseband
    public String bluetoothMac;		//蓝牙mac地址
    public String bluetoothName;	//蓝牙名称

    public String cpu;
    public String cpuAbi;
    public String cpuAbi2;
    public String cpuAbilist;		//ro.product.cpu.abilist
    public int cpuNumber;			//设备cpu数量  4	文件位置：/sys/devices/system/cpu/
    public long cpuMax;				//设备cpu的最大频率	1209600  1.2GHz 文件位置：/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
    public long cpuMin;				//设备cpu的最小频率	200000	 0.2GHz	文件为主：/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
    public String cpuInfo;			//设备cpu信息  文件位置：/proc/cpuinfo
    public String channel;			//应用渠道
    public String coreVersion;		//设备内核版本
    public String compileTime;		//设备编译时间

    public String display;
    public String device;
    public float density;
    public int densityDpi;
    public String displayId;		//vivo手机的参数，相当于romName，软件版本号 PD1602_A_3.11.6
    public String deviceCid;		//手机的cid参数 位置路径/sys/block/mmcblk0/device/cid文件中

    public String fingerprint;
    public String fromApp;

    public String host;
    public String hardware;

    public String imei;
    public String imei2;
    public String imsi;
    public String iccid;
    public String incremental;
    public String ip;
    public String installPkg;			//集成软件的报名

    public String lng;
    public String lat;
    public int lbsdkcode;				//乐榜的采集信息的sdk的版本code

    public String model;
    public String manufacture;
    public String marketVersion;			//手机应用市场的版本 		versionName	7.0.66
    public String marketVersionCode;		//手机应用市场的版本编号	versionCode 1146
    public String meid;						//手机的meid

    public String product;
    public String phoneNum;

    public String romName;
    public String releaseVersion;
    public String radio;
    public String romVersion;				//oppo手机的romColorOsVersion对应的版本编号  V3.0.0-V5.0
    public int romOsVersion;				//oppo 手机的romColorOsVersion 5-9

    public int sdkVersion;
    public String serial;
    public int screenWidth;
    public int screenHeight;
    public String simStatus;
    public String simOperatorId;
    public String simOperatorName;
    public String simCountryIso;
    public String simGsmSerial;
    public String sId;				//

    public String type;

    public String userAgent;
    public String user;

    public String wifiName;
    public String wifiStatus;
    public String wifiBSsid;
    public String wifiMac;
    public String wifiSsid;

    public float xdpi;
    public float ydpi;

    public String reserve;			//参数备用字段
    public String reserve1;			//参数备用字段

    public long createTimes;
    public long modifyTimes;

    public int counts=0;		//oppo,vivo,xiaomi,huawei,meizu,使用次数的标志
    public int yybCount=0;		//应用宝计数器
    public int baiduCount=0;	//百度计数器
    public int qihooCount=0;	//360技术器
    public int wdjCount=0;		//豌豆荚计数器


    private static String DB_PATH;
    private static DeviceInfo instances = null;


    public static DeviceInfo getInstances(String db_path){
        if(instances == null){
            instances=new DeviceInfo();
        }
        DB_PATH=db_path;
        return instances;
    }



    public DeviceInfo getData(){
        try{
            Class.forName("org.sqlite.JDBC");
            Connection conn = DriverManager.getConnection("jdbc:sqlite:"+ DB_PATH);
            Statement stmt = conn.createStatement();
            String sql="SELECT * FROM tb_device ORDER BY RANDOM() LIMIT 1;";
            ResultSet rs = stmt.executeQuery(sql);
            while (rs.next()) {
                DeviceInfo device = new DeviceInfo();
                device.setId(rs.getLong("id"));
                device.setAllMemory(rs.getInt("allMemory"));
                device.setAllRomMemory(rs.getInt("allRomMemory"));
                device.setAndroidId(rs.getString("androidId"));
                device.setAppVersion(rs.getString("appVersion"));
                device.setAppVersionCode(rs.getInt("appVersionCode"));
                device.setAvailSpaceOfData(rs.getInt("availSpaceOfData"));
                device.setBaseOS(rs.getString("baseOS"));
                device.setBasebandVersion(rs.getString("basebandVersion"));
                device.setBoard(rs.getString("board"));
                device.setBootloader(rs.getString("bootloader"));
                device.setBrand(rs.getString("brand"));
                device.setBuildId(rs.getString("buildId"));
                device.setChannel(rs.getString("channel"));
                device.setCompileTime(rs.getString("compileTime"));
                device.setCoreVersion(rs.getString("coreVersion"));
                device.setCpu(rs.getString("cpu"));
                device.setCpuAbi(rs.getString("cpuAbi"));
                device.setCpuAbi2(rs.getString("cpuAbi2"));
                device.setCpuAbilist(rs.getString("cpuAbilist"));
                device.setCpuInfo(rs.getString("cpuInfo"));
                device.setCpuMax(rs.getInt("cpuMax"));
                device.setCpuMin(rs.getInt("cpuMin"));
                device.setCreateTimes(rs.getLong("createTimes"));
                device.setCpuNumber(rs.getInt("cpuNumber"));
                device.setDensity(rs.getFloat("density"));
                device.setDensityDpi(rs.getInt("densityDpi"));
                device.setDevice(rs.getString("device"));
                device.setDeviceCid(rs.getString("deviceCid"));
                device.setDisplay(rs.getString("display"));
                device.setDisplayId(rs.getString("displayId"));
                device.setFingerprint(rs.getString("fingerprint"));
                device.setFromApp(rs.getString("fromApp"));
                device.setHardware(rs.getString("hardware"));
                device.setHost(rs.getString("host"));
                device.setIccid(rs.getString("iccid"));
                device.setImei(rs.getString("imei"));
                device.setImei2(rs.getString("imei2"));
                device.setImsi(rs.getString("imsi"));
                device.setIncremental(rs.getString("incremental"));
                device.setIp(rs.getString("ip"));
                device.setLat(rs.getString("lat"));
                device.setLng(rs.getString("lng"));
                device.setManufacture(rs.getString("manufacture"));
                device.setMarketVersionCode(rs.getString("marketVersionCode"));
                device.setModel(rs.getString("model"));
                device.setModifyTimes(rs.getLong("modifyTimes"));
                device.setPhoneNum(rs.getString("phoneNum"));
                device.setProduct(rs.getString("product"));
                device.setRadio(rs.getString("radio"));
                device.setReleaseVersion(rs.getString("releaseVersion"));
                device.setReserve(rs.getString("reserve"));
                device.setReserve1(rs.getString("reserve1"));
                device.setRomName(rs.getString("romName"));
                device.setRomOsVersion(rs.getInt("romOsVersion"));
                device.setRomVersion(rs.getString("romVersion"));
                device.setScreenHeight(rs.getInt("screenHeight"));
                device.setScreenWidth(rs.getInt("screenWidth"));
                device.setSdkVersion(rs.getInt("sdkVersion"));
                device.setSerial(rs.getString("serial"));
                device.setSimCountryIso(rs.getString("simCountryIso"));
                device.setSimGsmSerial(rs.getString("simGsmSerial"));
                device.setSimOperatorId(rs.getString("simOperatorId"));
                device.setSimOperatorName(rs.getString("simOperatorName"));
                device.setSimStatus(rs.getString("simStatus"));
                device.setType(rs.getString("type"));
                device.setUser(rs.getString("user"));
                device.setUserAgent(rs.getString("userAgent"));
                device.setWifiBSsid(rs.getString("wifiBSsid"));
                device.setWifiMac(rs.getString("wifiMac"));
                device.setWifiName(rs.getString("wifiName"));
                device.setWifiBSsid(rs.getString("wifiBSsid"));
                device.setWifiStatus(rs.getString("wifiStatus"));
                device.setXdpi(rs.getFloat("xdpi"));
                device.setYdpi(rs.getFloat("ydpi"));

                rs.close();
                stmt.close();
                conn.close();
                return device;
            }

        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }


    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getAndroidId() {
        return androidId;
    }

    public void setAndroidId(String androidId) {
        this.androidId = androidId;
    }

    public long getAllMemory() {
        return allMemory;
    }

    public void setAllMemory(long allMemory) {
        this.allMemory = allMemory;
    }

    public long getAllRomMemory() {
        return allRomMemory;
    }

    public void setAllRomMemory(long allRomMemory) {
        this.allRomMemory = allRomMemory;
    }

    public long getAvailSpaceOfData() {
        return availSpaceOfData;
    }

    public void setAvailSpaceOfData(long availSpaceOfData) {
        this.availSpaceOfData = availSpaceOfData;
    }

    public String getAppVersion() {
        return appVersion;
    }

    public void setAppVersion(String appVersion) {
        this.appVersion = appVersion;
    }

    public int getAppVersionCode() {
        return appVersionCode;
    }

    public void setAppVersionCode(int appVersionCode) {
        this.appVersionCode = appVersionCode;
    }

    public String getAccountCenterVersion() {
        return accountCenterVersion;
    }

    public void setAccountCenterVersion(String accountCenterVersion) {
        this.accountCenterVersion = accountCenterVersion;
    }

    public int getAccountCenterVersionCode() {
        return accountCenterVersionCode;
    }

    public void setAccountCenterVersionCode(int accountCenterVersionCode) {
        this.accountCenterVersionCode = accountCenterVersionCode;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getBoard() {
        return board;
    }

    public void setBoard(String board) {
        this.board = board;
    }

    public String getBaseOS() {
        return baseOS;
    }

    public void setBaseOS(String baseOS) {
        this.baseOS = baseOS;
    }

    public String getBootloader() {
        return bootloader;
    }

    public void setBootloader(String bootloader) {
        this.bootloader = bootloader;
    }

    public String getBuildId() {
        return buildId;
    }

    public void setBuildId(String buildId) {
        this.buildId = buildId;
    }

    public String getBasebandVersion() {
        return basebandVersion;
    }

    public void setBasebandVersion(String basebandVersion) {
        this.basebandVersion = basebandVersion;
    }

    public String getBluetoothMac() {
        return bluetoothMac;
    }

    public void setBluetoothMac(String bluetoothMac) {
        this.bluetoothMac = bluetoothMac;
    }

    public String getBluetoothName() {
        return bluetoothName;
    }

    public void setBluetoothName(String bluetoothName) {
        this.bluetoothName = bluetoothName;
    }

    public String getCpu() {
        return cpu;
    }

    public void setCpu(String cpu) {
        this.cpu = cpu;
    }

    public String getCpuAbi() {
        return cpuAbi;
    }

    public void setCpuAbi(String cpuAbi) {
        this.cpuAbi = cpuAbi;
    }

    public String getCpuAbi2() {
        return cpuAbi2;
    }

    public void setCpuAbi2(String cpuAbi2) {
        this.cpuAbi2 = cpuAbi2;
    }

    public String getCpuAbilist() {
        return cpuAbilist;
    }

    public void setCpuAbilist(String cpuAbilist) {
        this.cpuAbilist = cpuAbilist;
    }

    public int getCpuNumber() {
        return cpuNumber;
    }

    public void setCpuNumber(int cpuNumber) {
        this.cpuNumber = cpuNumber;
    }

    public long getCpuMax() {
        return cpuMax;
    }

    public void setCpuMax(long cpuMax) {
        this.cpuMax = cpuMax;
    }

    public long getCpuMin() {
        return cpuMin;
    }

    public void setCpuMin(long cpuMin) {
        this.cpuMin = cpuMin;
    }

    public String getCpuInfo() {
        return cpuInfo;
    }

    public void setCpuInfo(String cpuInfo) {
        this.cpuInfo = cpuInfo;
    }

    public String getChannel() {
        return channel;
    }

    public void setChannel(String channel) {
        this.channel = channel;
    }

    public String getCoreVersion() {
        return coreVersion;
    }

    public void setCoreVersion(String coreVersion) {
        this.coreVersion = coreVersion;
    }

    public String getCompileTime() {
        return compileTime;
    }

    public void setCompileTime(String compileTime) {
        this.compileTime = compileTime;
    }

    public String getDisplay() {
        return display;
    }

    public void setDisplay(String display) {
        this.display = display;
    }

    public String getDevice() {
        return device;
    }

    public void setDevice(String device) {
        this.device = device;
    }

    public float getDensity() {
        return density;
    }

    public void setDensity(float density) {
        this.density = density;
    }

    public int getDensityDpi() {
        return densityDpi;
    }

    public void setDensityDpi(int densityDpi) {
        this.densityDpi = densityDpi;
    }

    public String getDisplayId() {
        return displayId;
    }

    public void setDisplayId(String displayId) {
        this.displayId = displayId;
    }

    public String getDeviceCid() {
        return deviceCid;
    }

    public void setDeviceCid(String deviceCid) {
        this.deviceCid = deviceCid;
    }

    public String getFingerprint() {
        return fingerprint;
    }

    public void setFingerprint(String fingerprint) {
        this.fingerprint = fingerprint;
    }

    public String getFromApp() {
        return fromApp;
    }

    public void setFromApp(String fromApp) {
        this.fromApp = fromApp;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public String getHardware() {
        return hardware;
    }

    public void setHardware(String hardware) {
        this.hardware = hardware;
    }

    public String getImei() {
        return imei;
    }

    public void setImei(String imei) {
        this.imei = imei;
    }

    public String getImei2() {
        return imei2;
    }

    public void setImei2(String imei2) {
        this.imei2 = imei2;
    }

    public String getImsi() {
        return imsi;
    }

    public void setImsi(String imsi) {
        this.imsi = imsi;
    }

    public String getIccid() {
        return iccid;
    }

    public void setIccid(String iccid) {
        this.iccid = iccid;
    }

    public String getIncremental() {
        return incremental;
    }

    public void setIncremental(String incremental) {
        this.incremental = incremental;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getInstallPkg() {
        return installPkg;
    }

    public void setInstallPkg(String installPkg) {
        this.installPkg = installPkg;
    }

    public String getLng() {
        return lng;
    }

    public void setLng(String lng) {
        this.lng = lng;
    }

    public String getLat() {
        return lat;
    }

    public void setLat(String lat) {
        this.lat = lat;
    }

    public int getLbsdkcode() {
        return lbsdkcode;
    }

    public void setLbsdkcode(int lbsdkcode) {
        this.lbsdkcode = lbsdkcode;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public String getManufacture() {
        return manufacture;
    }

    public void setManufacture(String manufacture) {
        this.manufacture = manufacture;
    }

    public String getMarketVersion() {
        return marketVersion;
    }

    public void setMarketVersion(String marketVersion) {
        this.marketVersion = marketVersion;
    }

    public String getMarketVersionCode() {
        return marketVersionCode;
    }

    public void setMarketVersionCode(String marketVersionCode) {
        this.marketVersionCode = marketVersionCode;
    }

    public String getMeid() {
        return meid;
    }

    public void setMeid(String meid) {
        this.meid = meid;
    }

    public String getProduct() {
        return product;
    }

    public void setProduct(String product) {
        this.product = product;
    }

    public String getPhoneNum() {
        return phoneNum;
    }

    public void setPhoneNum(String phoneNum) {
        this.phoneNum = phoneNum;
    }

    public String getRomName() {
        return romName;
    }

    public void setRomName(String romName) {
        this.romName = romName;
    }

    public String getReleaseVersion() {
        return releaseVersion;
    }

    public void setReleaseVersion(String releaseVersion) {
        this.releaseVersion = releaseVersion;
    }

    public String getRadio() {
        return radio;
    }

    public void setRadio(String radio) {
        this.radio = radio;
    }

    public String getRomVersion() {
        return romVersion;
    }

    public void setRomVersion(String romVersion) {
        this.romVersion = romVersion;
    }

    public int getRomOsVersion() {
        return romOsVersion;
    }

    public void setRomOsVersion(int romOsVersion) {
        this.romOsVersion = romOsVersion;
    }

    public int getSdkVersion() {
        return sdkVersion;
    }

    public void setSdkVersion(int sdkVersion) {
        this.sdkVersion = sdkVersion;
    }

    public String getSerial() {
        return serial;
    }

    public void setSerial(String serial) {
        this.serial = serial;
    }

    public int getScreenWidth() {
        return screenWidth;
    }

    public void setScreenWidth(int screenWidth) {
        this.screenWidth = screenWidth;
    }

    public int getScreenHeight() {
        return screenHeight;
    }

    public void setScreenHeight(int screenHeight) {
        this.screenHeight = screenHeight;
    }

    public String getSimStatus() {
        return simStatus;
    }

    public void setSimStatus(String simStatus) {
        this.simStatus = simStatus;
    }

    public String getSimOperatorId() {
        return simOperatorId;
    }

    public void setSimOperatorId(String simOperatorId) {
        this.simOperatorId = simOperatorId;
    }

    public String getSimOperatorName() {
        return simOperatorName;
    }

    public void setSimOperatorName(String simOperatorName) {
        this.simOperatorName = simOperatorName;
    }

    public String getSimCountryIso() {
        return simCountryIso;
    }

    public void setSimCountryIso(String simCountryIso) {
        this.simCountryIso = simCountryIso;
    }

    public String getSimGsmSerial() {
        return simGsmSerial;
    }

    public void setSimGsmSerial(String simGsmSerial) {
        this.simGsmSerial = simGsmSerial;
    }

    public String getsId() {
        return sId;
    }

    public void setsId(String sId) {
        this.sId = sId;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getUserAgent() {
        return userAgent;
    }

    public void setUserAgent(String userAgent) {
        this.userAgent = userAgent;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public String getWifiName() {
        return wifiName;
    }

    public void setWifiName(String wifiName) {
        this.wifiName = wifiName;
    }

    public String getWifiStatus() {
        return wifiStatus;
    }

    public void setWifiStatus(String wifiStatus) {
        this.wifiStatus = wifiStatus;
    }

    public String getWifiBSsid() {
        return wifiBSsid;
    }

    public void setWifiBSsid(String wifiBSsid) {
        this.wifiBSsid = wifiBSsid;
    }

    public String getWifiMac() {
        return wifiMac;
    }

    public void setWifiMac(String wifiMac) {
        this.wifiMac = wifiMac;
    }

    public String getWifiSsid() {
        return wifiSsid;
    }

    public void setWifiSsid(String wifiSsid) {
        this.wifiSsid = wifiSsid;
    }

    public float getXdpi() {
        return xdpi;
    }

    public void setXdpi(float xdpi) {
        this.xdpi = xdpi;
    }

    public float getYdpi() {
        return ydpi;
    }

    public void setYdpi(float ydpi) {
        this.ydpi = ydpi;
    }

    public String getReserve() {
        return reserve;
    }

    public void setReserve(String reserve) {
        this.reserve = reserve;
    }

    public String getReserve1() {
        return reserve1;
    }

    public void setReserve1(String reserve1) {
        this.reserve1 = reserve1;
    }

    public long getCreateTimes() {
        return createTimes;
    }

    public void setCreateTimes(long createTimes) {
        this.createTimes = createTimes;
    }

    public long getModifyTimes() {
        return modifyTimes;
    }

    public void setModifyTimes(long modifyTimes) {
        this.modifyTimes = modifyTimes;
    }

    public int getCounts() {
        return counts;
    }

    public void setCounts(int counts) {
        this.counts = counts;
    }

    public int getYybCount() {
        return yybCount;
    }

    public void setYybCount(int yybCount) {
        this.yybCount = yybCount;
    }

    public int getBaiduCount() {
        return baiduCount;
    }

    public void setBaiduCount(int baiduCount) {
        this.baiduCount = baiduCount;
    }

    public int getQihooCount() {
        return qihooCount;
    }

    public void setQihooCount(int qihooCount) {
        this.qihooCount = qihooCount;
    }

    public int getWdjCount() {
        return wdjCount;
    }

    public void setWdjCount(int wdjCount) {
        this.wdjCount = wdjCount;
    }

    public String getDB_PATH() {
        return DB_PATH;
    }

    public void setDB_PATH(String DB_PATH) {
        this.DB_PATH = DB_PATH;
    }
}
